<!DOCTYPE html>


<html lang="zh-CN">


<head>
  <meta charset="utf-8" />
    
  <meta name="description" content="迎着朝阳的博客" />
  
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
  <title>
    Mac下python dyld ：Library not loaded 问题解决 |  迎着朝阳
  </title>
  <meta name="generator" content="hexo-theme-ayer">
  
  <link rel="shortcut icon" href="https://dxysun.com/static/yan.png" />
  
  
<link rel="stylesheet" href="/dist/main.css">

  
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Shen-Yu/cdn/css/remixicon.min.css">

  
<link rel="stylesheet" href="/css/custom.css">

  
  
<script src="https://cdn.jsdelivr.net/npm/pace-js@1.0.2/pace.min.js"></script>

  
  

  
<script>
var _hmt = _hmt || [];
(function() {
	var hm = document.createElement("script");
	hm.src = "https://hm.baidu.com/hm.js?aa994a8d65700b8835787dd39d079d7e";
	var s = document.getElementsByTagName("script")[0]; 
	s.parentNode.insertBefore(hm, s);
})();
</script>


</head>

</html>

<body>
  <div id="app">
    
      
    <main class="content on">
      <section class="outer">
  <article
  id="post-pythonForDyld"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h1 class="article-title sea-center" style="border-left:0" itemprop="name">
  Mac下python dyld ：Library not loaded 问题解决
</h1>
 

    </header>
     
    <div class="article-meta">
      <a href="/2021/01/30/pythonForDyld/" class="article-date">
  <time datetime="2021-01-30T10:03:47.000Z" itemprop="datePublished">2021-01-30</time>
</a>   
<div class="word_count">
    <span class="post-time">
        <span class="post-meta-item-icon">
            <i class="ri-quill-pen-line"></i>
            <span class="post-meta-item-text"> 字数统计:</span>
            <span class="post-count">1.5k</span>
        </span>
    </span>

    <span class="post-time">
        &nbsp; | &nbsp;
        <span class="post-meta-item-icon">
            <i class="ri-book-open-line"></i>
            <span class="post-meta-item-text"> 阅读时长≈</span>
            <span class="post-count">7 分钟</span>
        </span>
    </span>
</div>
 
    </div>
      
    <div class="tocbot"></div>




  
    <div class="article-entry" itemprop="articleBody">
       
  <p>今天在Mac下使用uwsgi运行Python  Flask的web程序时遇到了dyld: Library not loaded问题，记录一下解决方法</p>
<a id="more"></a>

<h1 id="问题"><a href="#问题" class="headerlink" title="问题"></a>问题</h1><p>今天本来想使用uwsgi在本地运行一下之前编写的flask程序，以便部署到服务器，结果遇到了一个比较坑的问题。</p>
<p>本来我的Mac没有安装uwsgi，使用如下命令安装了<code>uwsgi</code></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pip3 install uwsgi</span><br></pre></td></tr></table></figure>

<blockquote>
<p>我的电脑上有Python2 和 Python3 两个环境，pip对应Python2 ，pip3 对应 Python3</p>
</blockquote>
<p>安装了之后，运行flask官方文档的uwsgi的运行命令，结果遇到了如下问题</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">dongxiyan@MacBook-Pro ~ % uwsgi -s &#x2F;tmp&#x2F;app.sock --manage-script-name --mount &#x2F;app&#x3D;app:app</span><br><span class="line">dyld: Library not loaded: @rpath&#x2F;Python3.framework&#x2F;Versions&#x2F;3.8&#x2F;Python3</span><br><span class="line">  Referenced from: &#x2F;Users&#x2F;dongxiyan&#x2F;Library&#x2F;Python&#x2F;3.8&#x2F;bin&#x2F;uwsgi</span><br><span class="line">  Reason: image not found</span><br><span class="line">zsh: abort      uwsgi</span><br></pre></td></tr></table></figure>

<p>报了<code>dyld: Library not loaded</code>这个错，uwsgi运行不起来</p>
<h1 id="解决步骤"><a href="#解决步骤" class="headerlink" title="解决步骤"></a>解决步骤</h1><p>经过一通google、百度，发现原因是在运行uwsgi时找不到了Python3的动态库，即该路径<code>@rpath/Python3.framework/Versions/3.8/Python3</code>不存在。</p>
<p>不应该啊，我记得我的电脑装了Python3的，猜想是不是Python2和Python3乱了环境，uwsgi去找了Python2的库，查看Python2和Python3的具体路径</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">dongxiyan@MacBook-Pro ~ % which &#x2F;usr&#x2F;bin&#x2F;python</span><br><span class="line">&#x2F;usr&#x2F;bin&#x2F;python</span><br><span class="line">dongxiyan@MacBook-Pro ~ % otool -L &#x2F;usr&#x2F;bin&#x2F;python</span><br><span class="line">&#x2F;usr&#x2F;bin&#x2F;python:</span><br><span class="line">	&#x2F;System&#x2F;Library&#x2F;Frameworks&#x2F;Python.framework&#x2F;Versions&#x2F;2.7&#x2F;Python (compatibility version 2.7.0, current version 2.7.16)</span><br><span class="line">	&#x2F;usr&#x2F;lib&#x2F;libSystem.B.dylib (compatibility version 1.0.0, current version 1292.60.1)</span><br><span class="line">dongxiyan@MacBook-Pro ~ % which &#x2F;usr&#x2F;bin&#x2F;python3</span><br><span class="line">&#x2F;usr&#x2F;bin&#x2F;python3</span><br><span class="line">dongxiyan@MacBook-Pro ~ % otool -L &#x2F;usr&#x2F;bin&#x2F;python3</span><br><span class="line">&#x2F;usr&#x2F;bin&#x2F;python3:</span><br><span class="line">	&#x2F;usr&#x2F;lib&#x2F;libxcselect.dylib (compatibility version 1.0.0, current version 1.0.0)</span><br><span class="line">	&#x2F;usr&#x2F;lib&#x2F;libSystem.B.dylib (compatibility version 1.0.0, current version 1292.60.1)</span><br></pre></td></tr></table></figure>

<blockquote>
<p><code>otool -L /usr/bin/python</code> 查看/usr/bin/python 的依赖<br><code>otool</code>  Mac 下的反编译工具</p>
</blockquote>
<p>看到Python2 和 Python3 的依赖不一样，Python2下有依赖<code>/System/Library/Frameworks/Python.framework/Versions/2.7/Python</code>，按理说Python3也应该依赖<code>/System/Library/Frameworks/Python.framework/Versions/3.8/Python</code>，但是查出来的依赖里没有，查看<code>/System/Library/Frameworks/Python.framework/Versions/</code>路径下的文件，没有Python3的</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">dongxiyan@MacBook-Pro ~ % ls &#x2F;System&#x2F;Library&#x2F;Frameworks&#x2F;Python.framework&#x2F;Versions&#x2F;</span><br><span class="line">2.3	2.5	2.6	2.7	Current</span><br></pre></td></tr></table></figure>

<p>但是我在命令行下运行Python3是没问题的，说明Python3的库不在这个目录下<code>/System/Library/Frameworks/Python.framework/Versions/</code>，<code>/usr/bin/python3</code>的依赖应该也没有问题，因为<code>python3</code>能成功运行</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">dongxiyan@MacBook-Pro ~ % python3</span><br><span class="line">Python 3.8.2 (default, Dec 21 2020, 15:06:04) </span><br><span class="line">[Clang 12.0.0 (clang-1200.0.32.29)] on darwin</span><br><span class="line">Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.</span><br><span class="line">&gt;&gt;&gt;</span><br></pre></td></tr></table></figure>

<p>应该不是乱环境了，如果是乱环境了，应该是报<code>dyld: Library not loaded: @rpath/Python.framework/Versions/2.7/Python</code>这个错才对，估计原因是<code>/System/Library/Frameworks/Python3.framework/Versions/3.8/Python3</code> 这个的路径不存在，查一下，果然不存在</p>
<p><img src="https://tu.dxysun.com/20210130185501-20210130185501.png" alt="python"></p>
<p>但为什么会不存在的呢？我的Python3在本地运行时没问题的啊，那应该就是Python3的运行路径不在上面那个路径下，这个路径要怎样设置才正确呢？</p>
<p>然后继续谷歌百度<code>@rpath/Python3.framework/Versions/3.8/Python3</code>相关内容，查到<code>@rpath</code>的意思是可执行程序内部设置的一组路径，那解决办法就是把我的本地Python3的路径添加到<code>@rpath</code> 下应该就行了，根据Python2的依赖，估计<code>@rpath</code> 指的就是<code>/System/Library/Frameworks。</code></p>
<p>先找到本地Python3的运行路径，命令行下<code>import sys    sys.path</code></p>
<p><img src="https://tu.dxysun.com/20210130190650-20210130190651.png" alt=""></p>
<p>可以看到本地Python3的路径为<code>/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8</code>，原来使用的是Xcode的Python3环境，那把这个路径加到<code>@rpath</code> 下问题应该就解决了。</p>
<p>但是经过一通谷歌百度，也没找到<code>@rpath</code> 的添加方法，不过找到了修改<code>uwsgi</code>动态库依赖的方法，查看<code>uwsgi</code>的依赖</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">dongxiyan@MacBook-Pro ~ % otool -L &#x2F;Users&#x2F;dongxiyan&#x2F;Library&#x2F;Python&#x2F;3.8&#x2F;bin&#x2F;uwsgi</span><br><span class="line">&#x2F;Users&#x2F;dongxiyan&#x2F;Library&#x2F;Python&#x2F;3.8&#x2F;bin&#x2F;uwsgi:</span><br><span class="line">	&#x2F;usr&#x2F;lib&#x2F;libSystem.B.dylib (compatibility version 1.0.0, current version 1292.60.1)</span><br><span class="line">	&#x2F;usr&#x2F;lib&#x2F;libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)</span><br><span class="line">	&#x2F;usr&#x2F;local&#x2F;opt&#x2F;pcre&#x2F;lib&#x2F;libpcre.1.dylib (compatibility version 4.0.0, current version 4.12.0)</span><br><span class="line">	&#x2F;usr&#x2F;lib&#x2F;libexpat.1.dylib (compatibility version 7.0.0, current version 8.0.0)</span><br><span class="line">	&#x2F;System&#x2F;Library&#x2F;Frameworks&#x2F;CoreFoundation.framework&#x2F;Versions&#x2F;A&#x2F;CoreFoundation (compatibility version 150.0.0, current version 1770.255.0)</span><br><span class="line">	@rpath&#x2F;Python3.framework&#x2F;Versions&#x2F;3.8&#x2F;Python3 (compatibility version 3.8.0, current version 3.8.0)</span><br></pre></td></tr></table></figure>

<p>只要把<code>@rpath/Python3.framework/Versions/3.8/Python3</code>改成正确的路径应该就行了，在这里把它换成Xcode的Python3路径</p>
<p>修改命令如下</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">install_name_tool -change @rpath&#x2F;Python3.framework&#x2F;Versions&#x2F;3.8&#x2F;Python3 &#x2F;Applications&#x2F;Xcode.app&#x2F;Contents&#x2F;Developer&#x2F;Library&#x2F;Frameworks&#x2F;Python3.framework&#x2F;Versions&#x2F;3.8&#x2F;Python &#x2F;Users&#x2F;dongxiyan&#x2F;Library&#x2F;Python&#x2F;3.8&#x2F;bin&#x2F;uwsgi</span><br></pre></td></tr></table></figure>
<blockquote>
<p>工具install_name_tool可以用来修改应用程序对动态库的查找路径</p>
</blockquote>
<p>修改完成后运行uwsgi命令，成功运行，问题解决。</p>
<p><img src="https://tu.dxysun.com/20210130191539-20210130191541.png" alt=""></p>
<h1 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h1><p>这个问题真的好坑，折腾了我一下午，刚开始查到网上说的解决方案是使用brew升级一下Python3就可以，但是我并没有使用brew安装Python3，显然这个方案解决不了我这个问题，最终经过一番查抄，问题的根源就是Python3的动态库没找到，把Python3的动态库链接改为正确的路径就可以。</p>
<p>但是感觉修改<code>uwsgi</code>的动态库链接治标不治本，如果哪一天又安装了一个库，它也使用了<code>@rpath</code> ，这个错估计又要报出来了。</p>
<p>其他库报这个错时也可以用这个方法解决，不过这个错误正确的解决方法应该就是把本地Python3的路径加到<code>@rpath</code> 下，但目前还未找到如何添加，后面再研究一下吧，至少目前的问题解决了。</p>
<h1 id="参考"><a href="#参考" class="headerlink" title="参考"></a>参考</h1><p><a href="https://www.jianshu.com/p/4968e2585a94" target="_blank" rel="noopener">修复 dyld: Library not loaded</a></p>
<p><a href="https://blog.csdn.net/minger1202/article/details/71319308" target="_blank" rel="noopener">install_name_tool解决dyld: Library not loaded</a></p>
<p><a href="https://blog.csdn.net/qq_16135205/article/details/86645213" target="_blank" rel="noopener">mac加载路径@rpath</a></p>
<p><a href="https://www.cnblogs.com/csuftzzk/p/mac_run_path.html" target="_blank" rel="noopener">MacOS平台下@rpath在动态链接库中的应用</a></p>
<p><a href="https://www.dazhuanlan.com/2019/12/19/5dfb507c5304f/" target="_blank" rel="noopener">MAC: @rpath的坑</a></p>
<p><a href="https://blog.csdn.net/stven_king/article/details/81291919" target="_blank" rel="noopener">python3错误</a></p>
<p><a href="https://www.cnblogs.com/yrxns/p/11208861.html" target="_blank" rel="noopener">https://www.cnblogs.com/yrxns/p/11208861.html</a></p>
 
      <!-- reward -->
      
      <div id="reword-out">
        <div id="reward-btn">
          打赏
        </div>
      </div>
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
<div class="share-btn">
      <span class="share-sns share-outer">
        <i class="ri-share-forward-line"></i>
        分享
      </span>
      <div class="share-wrap">
        <i class="arrow"></i>
        <div class="share-icons">
          
          <a class="weibo share-sns" href="javascript:;" data-type="weibo">
            <i class="ri-weibo-fill"></i>
          </a>
          <a class="weixin share-sns wxFab" href="javascript:;" data-type="weixin">
            <i class="ri-wechat-fill"></i>
          </a>
          <a class="qq share-sns" href="javascript:;" data-type="qq">
            <i class="ri-qq-fill"></i>
          </a>
          <a class="douban share-sns" href="javascript:;" data-type="douban">
            <i class="ri-douban-line"></i>
          </a>
          <!-- <a class="qzone share-sns" href="javascript:;" data-type="qzone">
            <i class="icon icon-qzone"></i>
          </a> -->
          
          <a class="facebook share-sns" href="javascript:;" data-type="facebook">
            <i class="ri-facebook-circle-fill"></i>
          </a>
          <a class="twitter share-sns" href="javascript:;" data-type="twitter">
            <i class="ri-twitter-fill"></i>
          </a>
          <a class="google share-sns" href="javascript:;" data-type="google">
            <i class="ri-google-fill"></i>
          </a>
        </div>
      </div>
</div>

<div class="wx-share-modal">
    <a class="modal-close" href="javascript:;"><i class="ri-close-circle-line"></i></a>
    <p>扫一扫，分享到微信</p>
    <div class="wx-qrcode">
      <img src="//api.qrserver.com/v1/create-qr-code/?size=150x150&data=https://dxysun.com/2021/01/30/pythonForDyld/" alt="微信分享二维码">
    </div>
</div>

<div id="share-mask"></div>  
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/python/" rel="tag">python</a></li></ul>

    </footer>
  </div>

   
  <nav class="article-nav">
    
      <a href="/2021/01/31/pythonForFlask/" class="article-nav-link">
        <strong class="article-nav-caption">上一篇</strong>
        <div class="article-nav-title">
          
            python Flask使用教程
          
        </div>
      </a>
    
    
      <a href="/2021/01/16/gitForHookCommit/" class="article-nav-link">
        <strong class="article-nav-caption">下一篇</strong>
        <div class="article-nav-title">git钩子应用之修改提交的commit信息</div>
      </a>
    
  </nav>

  
   
  
</article>

</section>
      <footer class="footer">
  <div class="outer">
    <ul>
      <li>
        Copyrights &copy;
        2015-2024
        <i class="ri-heart-fill heart_icon"></i> dxysun
      </li>
    </ul>
    <ul>
      <li>
        
        
        
        由 <a href="https://hexo.io" target="_blank">Hexo</a> 强力驱动
        <span class="division">|</span>
        主题 - <a href="https://github.com/Shen-Yu/hexo-theme-ayer" target="_blank">Ayer</a>
        
      </li>
    </ul>
    <ul>
      <li>
        
        
        <span>
  <span><i class="ri-user-3-fill"></i>访问人数:<span id="busuanzi_value_site_uv"></span></s>
  <span class="division">|</span>
  <span><i class="ri-eye-fill"></i>浏览次数:<span id="busuanzi_value_page_pv"></span></span>
</span>
        
      </li>
    </ul>
    <ul>
      
        <li>
          <a href="https://beian.miit.gov.cn" target="_black" rel="nofollow">豫ICP备17012675号-1</a>
        </li>
        
    </ul>
    <ul>
      
    </ul>
    <ul>
      <li>
        <!-- cnzz统计 -->
        
      </li>
    </ul>
  </div>
</footer>
      <div class="float_btns">
        <div class="totop" id="totop">
  <i class="ri-arrow-up-line"></i>
</div>

<div class="todark" id="todark">
  <i class="ri-moon-line"></i>
</div>

      </div>
    </main>
    <aside class="sidebar on">
      <button class="navbar-toggle"></button>
<nav class="navbar">
  
  <div class="logo">
    <a href="/"><img src="https://dxysun.com/static/logo.png" alt="迎着朝阳"></a>
  </div>
  
  <ul class="nav nav-main">
    
    <li class="nav-item">
      <a class="nav-item-link" href="/">主页</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/archives">归档</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/categories">分类</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags">标签</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/photos">相册</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/friends">友链</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/about">关于我</a>
    </li>
    
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      
      <a class="nav-item-link nav-item-search"  title="搜索">
        <i class="ri-search-line"></i>
      </a>
      
      
      <a class="nav-item-link" target="_blank" href="/atom.xml" title="RSS Feed">
        <i class="ri-rss-line"></i>
      </a>
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
    </aside>
    <script>
      if (window.matchMedia("(max-width: 768px)").matches) {
        document.querySelector('.content').classList.remove('on');
        document.querySelector('.sidebar').classList.remove('on');
      }
    </script>
    <div id="mask"></div>

<!-- #reward -->
<div id="reward">
  <span class="close"><i class="ri-close-line"></i></span>
  <p class="reward-p"><i class="ri-cup-line"></i>请我喝杯咖啡吧~</p>
  <div class="reward-box">
    
    <div class="reward-item">
      <img class="reward-img" src="https://tu.dxysun.com/alipay-20201219151322.jpg">
      <span class="reward-type">支付宝</span>
    </div>
    
    
    <div class="reward-item">
      <img class="reward-img" src="https://tu.dxysun.com/weixin-20201219151346.png">
      <span class="reward-type">微信</span>
    </div>
    
  </div>
</div>
    
<script src="/js/jquery-2.0.3.min.js"></script>


<script src="/js/lazyload.min.js"></script>

<!-- Tocbot -->


<script src="/js/tocbot.min.js"></script>

<script>
  tocbot.init({
    tocSelector: '.tocbot',
    contentSelector: '.article-entry',
    headingSelector: 'h1, h2, h3, h4, h5, h6',
    hasInnerContainers: true,
    scrollSmooth: true,
    scrollContainer: 'main',
    positionFixedSelector: '.tocbot',
    positionFixedClass: 'is-position-fixed',
    fixedSidebarOffset: 'auto'
  });
</script>

<script src="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.css">
<script src="https://cdn.jsdelivr.net/npm/justifiedGallery@3.7.0/dist/js/jquery.justifiedGallery.min.js"></script>

<script src="/dist/main.js"></script>

<!-- ImageViewer -->

<!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" style="display:none" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/default-skin/default-skin.min.css">
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe-ui-default.min.js"></script>

<script>
    function viewer_init() {
        let pswpElement = document.querySelectorAll('.pswp')[0];
        let $imgArr = document.querySelectorAll(('.article-entry img:not(.reward-img)'))

        $imgArr.forEach(($em, i) => {
            $em.onclick = () => {
                // slider展开状态
                // todo: 这样不好，后面改成状态
                if (document.querySelector('.left-col.show')) return
                let items = []
                $imgArr.forEach(($em2, i2) => {
                    let img = $em2.getAttribute('data-idx', i2)
                    let src = $em2.getAttribute('data-target') || $em2.getAttribute('src')
                    let title = $em2.getAttribute('alt')
                    // 获得原图尺寸
                    const image = new Image()
                    image.src = src
                    items.push({
                        src: src,
                        w: image.width || $em2.width,
                        h: image.height || $em2.height,
                        title: title
                    })
                })
                var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, {
                    index: parseInt(i)
                });
                gallery.init()
            }
        })
    }
    viewer_init()
</script>

<!-- MathJax -->

<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
      tex2jax: {
          inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
          processEscapes: true,
          skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
      }
  });

  MathJax.Hub.Queue(function() {
      var all = MathJax.Hub.getAllJax(), i;
      for(i=0; i < all.length; i += 1) {
          all[i].SourceElement().parentNode.className += ' has-jax';
      }
  });
</script>

<script src="https://cdn.jsdelivr.net/npm/mathjax@2.7.6/unpacked/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script>
  var ayerConfig = {
    mathjax: true
  }
</script>

<!-- Katex -->

<!-- busuanzi  -->


<script src="/js/busuanzi-2.3.pure.min.js"></script>


<!-- ClickLove -->

<!-- ClickBoom1 -->

<!-- ClickBoom2 -->

<!-- CodeCopy -->


<link rel="stylesheet" href="/css/clipboard.css">

<script src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js"></script>
<script>
  function wait(callback, seconds) {
    var timelag = null;
    timelag = window.setTimeout(callback, seconds);
  }
  !function (e, t, a) {
    var initCopyCode = function(){
      var copyHtml = '';
      copyHtml += '<button class="btn-copy" data-clipboard-snippet="">';
      copyHtml += '<i class="ri-file-copy-2-line"></i><span>COPY</span>';
      copyHtml += '</button>';
      $(".highlight .code pre").before(copyHtml);
      $(".article pre code").before(copyHtml);
      var clipboard = new ClipboardJS('.btn-copy', {
        target: function(trigger) {
          return trigger.nextElementSibling;
        }
      });
      clipboard.on('success', function(e) {
        let $btn = $(e.trigger);
        $btn.addClass('copied');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-checkbox-circle-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPIED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-checkbox-circle-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
      clipboard.on('error', function(e) {
        e.clearSelection();
        let $btn = $(e.trigger);
        $btn.addClass('copy-failed');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-time-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPY FAILED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-time-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
    }
    initCopyCode();
  }(window, document);
</script>


<!-- CanvasBackground -->


<script src="/js/dz.js"></script>



    
  </div>
</body>

</html>